package com.aaa.controller;


import com.aaa.entity.MyReturn;
import com.aaa.service.TestResultSdsService;
import com.aaa.service.TesterSDSService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author yudejie2020
 */
@Controller
@RequestMapping("resultSds")
public class TestResultSdsController extends BaseController{
    MyReturn myReturn=new MyReturn();
    @Autowired
    private TestResultSdsService testResultSdsService;
@Autowired
    private TesterSDSService testerSDSService;
@RequestMapping("deleteTestResultSdsById.do")
@ResponseBody
public MyReturn deleteTestResultSdsById(Integer id){
    boolean deleteTesterById = testerSDSService.deleteTesterById(id);
    boolean deleteTestResultSdsById = testResultSdsService.deleteTestResultSdsById(id);
    if (deleteTesterById&&deleteTestResultSdsById){
        return super.getSuccessReturn(myReturn);
    }
    return super.getFailReturn(myReturn);

}
@RequestMapping("deleteTestResultBatch.do")
@ResponseBody
public MyReturn deleteTestResultBatch(String id){
    boolean deleteTestResultSdsBatch = testResultSdsService.deleteTestResultSdsBatch(id);
    boolean deleteTesterBatch = testerSDSService.deleteTesterBatch(id);
    if (deleteTesterBatch&&deleteTestResultSdsBatch){
        return  super.getSuccessReturn(myReturn);
    }
    return super.getFailReturn(myReturn);
}




    /**
     * 接收前台传回的json参数
     *
     */
    @RequestMapping("resultSds.do")
    @ResponseBody
    public MyReturn resultSds(String res){
        System.out.println(res);
        //转list<map>
        List<Map> maps = JSON.parseArray(res, Map.class);
        boolean b=testResultSdsService.insertTestSds(maps);
        if (b){
            return super.getSuccessReturn(myReturn);
        }
        return super.getFailReturn(myReturn);
    }


}
